import { Injectable } from '@nestjs/common';
import { JwtService as NestJwtService } from '@nestjs/jwt';
@Injectable()
export class FrontAuthService {
    constructor(private readonly jwtService: NestJwtService) { }

    // 生成 JWT 令牌
    generateToken(payload: object): string {
        return this.jwtService.sign(payload);
    }

    // 验证 JWT 令牌
    verifyToken(token: string): object | null {
        try {
            return this.jwtService.verify(token);
        } catch (error) {
            return null; // 令牌无效或已过期
        }
    }
}
